package java8;

import java8.entity.Employee;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class LambdaFilterStrength {
    public static void main(String[] args) {
        Employee e1 = new Employee(1, 22, "F", "aa", "aa");
        Employee e2 = new Employee(2, 23, "M", "bb", "bb");
        Employee e3 = new Employee(3, 24, "F", "cc", "cc");
        Employee e4 = new Employee(4, 25, "M", "dd", "dd");
        Employee e5 = new Employee(5, 26, "M", "ee", "ee");
        Employee e6 = new Employee(6, 27, "F", "gg", "gg");

        List<Employee> employees = Arrays.asList(e1, e2, e3, e4, e5, e6);

        List<Employee> employeeFilter = employees.stream()
                //.filter(e -> e.getAge() > 24 && e.getGender().equals("M"))

                //用定义的谓词 Predicate 来进行操作 (这样写的好处就是可以复用)
                .filter(Employee.thanAge.and(Employee.genderM))//用 and, or, negate 也可以用　
                .collect(Collectors.toList());

        System.out.println(employeeFilter);
    }
}
